package com.diandian.backend.store.controller;

import com.diandian.backend.store.param.*;
import com.diandian.backend.store.service.StoreDouyinLifeStoreInfoService;
import com.diandian.base.boot.starter.response.BaseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


/**
 * [门店]抖音本地生活门店信息表
 */
@RestController
@RequestMapping("/douyin/life/store/info")
public class DouyinLifeStoreInfoController {

    @Autowired
    private StoreDouyinLifeStoreInfoService douyinLifeStoreInfoService;

    @PostMapping("/page")
    public BaseResult page(@RequestBody StoreDouyinLifeStoreInfoPageParam param) {
        return new BaseResult(0, "success", douyinLifeStoreInfoService.page(param.toDTO()));
    }

    @PostMapping("/detail")
    public BaseResult getDetail(@RequestBody StoreDouyinLifeStoreInfoDetailParam param) {
        param.check();
        return new BaseResult(0, "success", douyinLifeStoreInfoService.getDetail(param.toDTO()));
    }

    /**
     * 根据线上门店编码或线下门店编码查询门店信息
     */
    @PostMapping("/detail/code")
    public BaseResult getDetailByCode(@RequestBody StoreDouyinLifeStoreInfoDetailByCodeParam param) {
        param.check();
        return new BaseResult(0, "success", douyinLifeStoreInfoService.getDetail(param.toDTO()));
    }

    @PostMapping("/updateById")
    public BaseResult updateById(@RequestBody StoreDouyinLifeStoreInfoUpdateByIdParam param) {
        param.check();
        douyinLifeStoreInfoService.updateById(param.toDTO());
        return new BaseResult(0, "success", null);
    }

    @PostMapping("/deleteById")
    public BaseResult deleteById(@RequestBody StoreDouyinLifeStoreInfoDeleteByIdParam param) {
        param.check();
        douyinLifeStoreInfoService.deleteById(param.toDTO());
        return new BaseResult(0, "success", null);
    }

    @PostMapping("/add")
    public BaseResult add(@RequestBody StoreDouyinLifeStoreInfoAddParam param) {
        param.check();
        douyinLifeStoreInfoService.add(param.toDTO());
        return new BaseResult(0, "success", null);
    }

    @PostMapping("/list")
    public BaseResult list(@RequestBody StoreDouyinLifeStoreInfoListParam param) {
        param.check();
        return new BaseResult(0, "success", douyinLifeStoreInfoService.getList(param.toDTO()));
    }

}